package com.anjie.powerproject.common;

import jdk.nashorn.internal.runtime.regexp.joni.Regex;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 常量集合
 */
public class Constants {

    public static final String PYTHON_DIR = "static/python/";
    /**
     * 模型存放路径
     */
    public static final String MODEL_DIR = "model/";

    public static final String ELECTRIC_MODEL_DIR = MODEL_DIR + "model_%s";

    public static final String ENERGY_MODEL_DIR = MODEL_DIR + "model_%s";

    /**
     * 创建模型时预处理数据文件存放路径
     */
    public static final String CREATE_DATA_DIR = "train/";

    public static final String ELECTRIC_CREATE_DATA_DIR = CREATE_DATA_DIR + "train_%s";

    public static final String ENERGY_CREATE_DATA_DIR = CREATE_DATA_DIR + "train_%s";

    /**
     * 预测数据时预处理数据文件存放路径
     */
    public static final String PREDICT_DATA_DIR = "test/";

    public static final String ELECTRIC_PREDICT_DATA_DIR = PREDICT_DATA_DIR + "test_%s";

    public static final String ENERGY_PREDICT_DATA_DIR = PREDICT_DATA_DIR + "test_%s";

    /**
     * 扩展文件存放路径
     */
    public static final String EXTRA_FILE_DIR = "joinfile/";

    public static final String ELECTRIC_EXTRA_FILE_DIR = EXTRA_FILE_DIR + "join_%s";

    public static final String ENERGY_EXTRA_FILE_DIR = EXTRA_FILE_DIR + "join_%s";

    // 根据设备编号匹配
    public static final String MODEL_INI_FILE = "model/model_%s/model_%s.ini";

    // 如果匹配不上，使用这个配置文件
    public static final String DEFAULT_INI_FILE = "common/model.ini";

    /**
     * 判断日期合法性的正则表达式
     */
    public static final String DATA_RE_STR = "(([0-9]{3}[1-9]|[0-9]{2}[1-9][0-9]{1}|[0-9]{1}[1-9][0-9]{2}|[1-9][0-9]{3})[-/.]{0,1}(((0[13578]|1[02])[-/.]{0,1}(0[1-9]|[12][0-9]|3[01]))|((0[469]|11)[-/.]{0,1}(0[1-9]|[12][0-9]|30))|(02[-/.]{0,1}(0[1-9]|[1][0-9]|2[0-8]))))|((([0-9]{2})(0[48]|[2468][048]|[13579][26])|((0[48]|[2468][048]|[3579][26])00))[-/.]{0,1}02[-/.]{0,1}29)";

    public static final Regex DATE_RE = new Regex(DATA_RE_STR);

    /**
     * 默认表头
     */
    public static final List<String> COLUMNS = Arrays.asList(
            "sdate", "energy", "day_t_max", "day_t_min", "day_t_mean", "day_wind", "day_hum_max",
            "day_hum_min", "day_weather", "holiday", "weekyear", "seasons", "month", "day",
            "week1", "week2", "week3", "week4", "week5", "week6", "week7", "supply_cold", "supply_heat"
    );

    /**
     * 默认表头对应中文
     */
    public static final List<String> COLUMNS_CHS = Arrays.asList(
            "时间(天)", "能量", "最高温", "最低温", "平均温", "风速", "最高湿度", "最低湿度", "天气"
            , "节假日", "周数", "季度", "月份", "日数", "周一", "周二", "周三", "周四", "周五", "周六",
            "周日", "供冷季", "供暖季"
    );

    public static final Map<String, String> COLUMN_MAP = new HashMap<>();
    static {
        COLUMN_MAP.put("sdate", "时间(天)");
        COLUMN_MAP.put("day_t_max", "天最高温");
        COLUMN_MAP.put("day_t_min", "天最低温");
        COLUMN_MAP.put("day_wind", "天风速");
        COLUMN_MAP.put("day_hum_max", "天最高湿度");
        COLUMN_MAP.put("day_hum_min", "天最低湿度");
        COLUMN_MAP.put("day_weather", "天气");
        COLUMN_MAP.put("day_t_mean", "天平均温度");
        COLUMN_MAP.put("m_average_day_t_max", "月最高平均温度");
        COLUMN_MAP.put("m_average_day_t_min", "月最低平均温度");
        COLUMN_MAP.put("holiday", "节假日");
        COLUMN_MAP.put("weekyear", "年中周数");
        COLUMN_MAP.put("weekdays", "星期数");
        COLUMN_MAP.put("season", "季度");
        COLUMN_MAP.put("holiday_plus_season", "节假日-季度");
        COLUMN_MAP.put("month", "月份");
        COLUMN_MAP.put("day", "日数");
        COLUMN_MAP.put("data", "数据");
    }

    public static final List<String> ELECTRIC_DEFAULT_COLUMNS = Arrays.asList(
            "day_t_max","day_t_min","day_t_mean","weekdays","holiday","season","m_average_day_t_max","m_average_day_t_min"
    );

    public static final List<String> ENERGY_DEFAULT_COLUMNS = Arrays.asList(
            "day_t_max","day_t_min","day_t_mean","holiday","seasons","day_wind","day_hum_max","day_hum_min","day_weather","holiday_plus_seasons"
    );

    public static final Long EXPIRE_SPAN = 3600000L;

    /**
     * 使用的python版本
     * 如果是3.0+则填python3
     * 否则填python
     */
    public static final String PYTHON_VERSION = "python3";
}
